package com.dgw.springbootrabbitmq.config;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.SimpleMessageConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @program: spring-boot-rabbitmq
 * @description:
 * @author: Mr.Dai
 * @create: 2020-02-23 21:21
 **/
@Configuration
public class config {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @PostConstruct
    public void simpleMessageListenerContainer(){
        rabbitTemplate.setMessageConverter(new Jackson2JsonMessageConverter());
        // 默认采用下面的这种转换器
         //rabbitTemplate.setMessageConverter(new SimpleMessageConverter());
    }
}
